<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户</title>
    <link rel="stylesheet" href="../static/css3/css.css">
    <script src="../static/js/jquery-1.8.3.js"></script>
    <script src="../static/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<table>
    <a href="/user/downLoadExcel">下载报告</a>
    <tr style="font-weight: bold">
        <td>用户编号</td>
        <td>用户名</td>
        <td>用户密码</td>
        <td>真实姓名</td>
        <td>邮箱</td>
        <td>手机号</td>
        <td>备注</td>
        <td>冻结状态</td>
        <td>注册日期</td>
        <td>性别</td>
        <td>爱好</td>
        <td>操作</td>
    </tr>
    <tr th:each="user:${list.getRecords()}">
        <td th:text="${user.usersId}"></td>
        <td th:text="${user.userName}"></td>
        <td th:text="${user.password}"></td>
        <td th:text="${user.trueName}"></td>
        <td th:text="${user.email}"></td>
        <td th:text="${user.phone}"></td>
        <td th:text="${user.comments}"></td>
        <td th:switch="${user.lockState}">
            <span th:case="0">未冻结</span>
            <span th:case="1">已冻结</span>
        </td>
        <td th:text="${user.registerDate}"></td>
        <td th:switch="${user.sex}">
            <span th:case="2">女</span>
            <span th:case="1">男</span>
        </td>
        <td th:text="${user.love}"></td>
        <td>
            <a href="http://www.baidu.com">百度</a>
        </td>
    </tr>
    <tr>
        <td colspan="20">
            <input type="button" value="首页" th:onclick="|page(1)|">
            <input type="button" value="上页" th:onclick="|page(${list.getCurrent() == 1 ? 1 : list.getCurrent() - 1})|">
        </td>
    </tr>
</table>
</body>
<script>
    /*分页展示*/
    function page(page) {
        location.href = '/user/list?page=' + page
    }

    /* 删除 */
    function delUser(usersId) {
        $.ajax({
            url : "/user/delete?usersId=" + usersId,
            type : "Get",
            dataType : "json",
            contentType : "application/json",
            success : function (data) {
                if (data > 0) {
                    alert("删除成功");
                    /* location.reload() */
                } else {
                    alert("删除失败")
                }
            }
        })
    }
</script>
</html>